package com.dy.design_pattern_study.chain_of_responsibility_pattern.dome2;

import com.dy.design_pattern_study.chain_of_responsibility_pattern.dome2.impl.ConcreteHandler1;
import com.dy.design_pattern_study.chain_of_responsibility_pattern.dome2.impl.ConcreteHandler2;
import com.dy.design_pattern_study.chain_of_responsibility_pattern.dome2.impl.ConcreteHandler3;

/**
 * @CreateBy zhangdingyi
 * @Date 2023-04-22
 * @Content
 */
public class client {
    public static void main(String[] args) {
        Handler h1 = new ConcreteHandler1();
        h1.setName("h1");
        Handler h2 = new ConcreteHandler2();
        h2.setName("h2");
        Handler h3 = new ConcreteHandler3();
        h3.setName("h3");

        //设置职责层级
        h1.setSuccessor(h2);
        h2.setSuccessor(h3);

        int[] requests = {2, 5, 14, 22, 18, 3, 27, 20};

        for (int request : requests) {
            h1.handleRequest(request);
        }
    }
}
